import type { MenuType } from '@/types/menu'
import type { RoleTable } from '@/types/role'
import type { UserInfo } from '@/types/sign'
import { getUseRoleId } from '@/util/token'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  // 用户的基本信息
  let info: UserInfo | null = {}
  // 用户正在使用的角色id
  let useRoleId: number | null = getUseRoleId()
  // 用户角色名集合
  let roleNames: RoleTable[] = []
  // 用户的菜单数据
  let menus: MenuType[] = []

  return { info, useRoleId, roleNames, menus }
})
